using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
//using System.Drawing;

namespace WTCOTH
{
    class map : Microsoft.Xna.Framework.Game
    {
        //private Bitmap mapImage;
        Texture2D mapImage; 
        GraphicsDeviceManager graphics;

        public map()
        {
            graphics = new GraphicsDeviceManager(this);
            this.graphics.IsFullScreen = true;
            Content.RootDirectory = "Content";
        }
        public int get_tile_type(int x, int y)
        {
           // mapImage =  this.Content.Load<Texture2D>("Content/texture/sand");

            Color[] texColors = new Color[mapImage.Height*mapImage.Width];



            mapImage.GetData(texColors);

            //return mapImage.GetPixel(x, y).R;
            /*switch( mapImage.GetPixel(x,y).R )
            {
                case 237: return 1;
                default: return 0;
            }*/
            return texColors[((x * mapImage.Width) + y)].R;
        }

        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }


        public bool load_map(Texture2D map)
        {
           

           // try
            //{
            this.mapImage = map;
           // }
            //catch (Exception e)
           // {
          //      return false;
          //  }
            return true;
        }

        public int get_map_width()
        {
            return get_map_width("tile");
        }

        public int get_map_height()
        {
            return get_map_height("tile");
        }

        public int get_map_width(string unit)
        {
            
            switch (unit)
            {
                case "pixel": return mapImage.Width;
                case "tile":
                default: return mapImage.Width * 32;
            }
        }

        public int get_map_height(string unit)
        {
            switch (unit)
            {
                case "pixel": return mapImage.Height;
                case "tile":
                default: return mapImage.Height * 32;
            }
        }
    }
}
